package com.ihr360.payroll.model.dto.salary.task.period.embeddable;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.ihr360.commons.model.meta.table.DynamicCell;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class StaffSalarySnapshot implements Serializable {
    /**
     * 分段开始时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8" )
    private Date startOn;
    /**
     * 分段结束时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8" )
    private Date endOn;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Map<String, DynamicCell> data;

    public Date getStartOn() {
        return startOn;
    }

    public void setStartOn(Date startOn) {
        this.startOn = startOn;
    }

    public Date getEndOn() {
        return endOn;
    }

    public void setEndOn(Date endOn) {
        this.endOn = endOn;
    }

    public Map<String, DynamicCell> getData() {
        return data;
    }

    public void setData(Map<String, DynamicCell> data) {
        this.data = data;
    }

    public void addData(String code, DynamicCell cell) {
        if (data == null) {
            data = new HashMap<>();
        }
        if (cell == null || cell.originValue() == null) {
            data.remove(code);
        }else{
            data.put(code,cell);
        }
    }
    public void addData(String code, String cell) {
        if (data == null) {
            data = new HashMap<>();
        }
        if (cell == null) {
            data.remove(code);
        }else{
            data.put(code,new DynamicCell(cell));
        }
    }
}